package com.umakr.ax.core.config;

import com.google.common.collect.Lists;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author gx
 */
@ConfigurationProperties(prefix = "base.redis")
public class RedissonProperties {
     /** SingleServer */
    String singleAddress;

    /** nodeAddresses */
    List<String> nodeAddresses = Lists.newArrayList();

    /**MasterSlaveServers*/
    String masterAddress;
    String password;
    /**
     * SlaveServers
     */
    private Set<String> slaveAddresses = new HashSet<>();


    public String getSingleAddress() {
        return singleAddress;
    }

    public void setSingleAddress(String singleAddress) {
        this.singleAddress = singleAddress;
    }

    public List<String> getNodeAddresses() {
        return nodeAddresses;
    }

    public void setNodeAddresses(String... nodeAddresses) {
        if (nodeAddresses != null) {
            for (int i = 0; i < nodeAddresses.length; i++) {
                this.nodeAddresses.add(nodeAddresses[i]);
            }
        }
    }

    public String getMasterAddress() {
        return masterAddress;
    }

    public void setMasterAddress(String masterAddress) {
        this.masterAddress = masterAddress;
    }

    public Set<String> getSlaveAddresses() {
        return slaveAddresses;
    }

    public void setSlaveAddresses(String ...slaveAddresses) {
        if (slaveAddresses != null) {
            for (int i = 0; i < slaveAddresses.length; i++) {
                this.slaveAddresses.add(slaveAddresses[i]);
            }
        }
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
